<template>
	<view class="">
		<u-navbar :is-back="true" :border-bottom="false" title="管理信息" height="46" title-color="#333" :title-bold="true"
		 :title-size="36">
			<view class="navbar-right" slot="right" @click="Store">
				确认
			</view>
		</u-navbar>
		<view class="textarea_box">
			<u-form-item label-width="150" label="管理级别" prop="bzz" class="name-box" :label-style="labelStyle">
				<u-radio-group v-model="form.gljb" v-if="form.gljb">
					<u-radio @change="radioChange" v-for="(item, index) in adminjb" :key="index" :name="item.name">
						{{item.name}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form :model="form" :rules="rules" ref="uForm" :errorType="errorType">
				<u-form-item label-width="150" :label-position="labelPosition" label="管理职位" prop="glzw" class="name-box"
				 :label-style="labelStyle">
					<u-input placeholder="请选择管理职位" v-model="form.glzw.name" type="text" :custom-style="{fontSize: '30rpx',}" :height="30"
					 @click="show=true" :clearable="false"></u-input>
					<u-picker v-model="show" mode="selector" :range="typegz" range-key="name" @confirm="confirmgz"></u-picker>
				</u-form-item>
				<u-form-item label-width="150" :label-position="labelPosition" label="期望行业" prop="qwhy" class="name-box"
				 :label-style="labelStyle">
					<u-input placeholder="请输入期望行业" v-model="form.qwhy" type="text" :custom-style="{fontSize: '30rpx',}" :height="30"></u-input>
				</u-form-item>
				<u-form-item label-width="150" :label-position="labelPosition" label="重要业绩" prop="zyyj" class="name-box"
				 :label-style="labelStyle">
					<u-input placeholder="请输入重要业绩" v-model="form.zyyj" type="text" :custom-style="{fontSize: '30rpx',}" :height="30"></u-input>
				</u-form-item>
			</u-form>
			<u-toast ref="uToast" />
		</view>

	</view>

</template>

<script>
	export default {
		data() {
			return {
				id: "",
				show: false,
				gljbid: "",
				form: {
					gljb: "",
					glzw: "",
					qwhy: "",
					zyyj: "",
				},
				typegz: [],
				rules: {

				},
				adminjb: [{
					id: 6,
					name: "高管"
				}, {
					id: 7,
					name: "中层"
				}],
				errorType: ['message'],
				labelPosition: "top",
				labelStyle: {
					height: "36rpx",
					fontSize: "24rpx",
					color: "#666666",
				},
			}
		},
		async onLoad(options) {
			this.id = options.id
			if (options.index) {
				this.index = options.index
			}
			await this.resumemy(options.id)
			// await this.lCodedata()
		},
		methods: {
			radioChange(e) {
				this.form.gljb = e
				this.gljbid = this.adminjb.filter(item => item.name == e)[0].id
				this.lCodedata(this.gljbid)

			},
			async resumemy(id) {
				let params = {
					ak: this.$store.state.token,
					cmd: 'lPeople_myquery',
					para: {
						"id": id,
					}
				}
				const res = await this.$u.api.resumedata(params)
				await this.lCodedata(res.Data.gljb)
				this.gljbid = res.Data.gljb
				this.form.gljb = this.adminjb.filter(item => item.id == res.Data.gljb)[0].name
				this.form.glzw = this.typegz.filter(item => item.id == res.Data.glzw)[0]
				this.form.qwhy = res.Data.qwhy
				this.form.zyyj = res.Data.zyyj
			},
			async lCodedata(gljbid) {
				let params = {
					cmd: 'lCode_list_proc',
					para: {
						"pageindex": 1,
						"pagesize": 1000
					}
				}
				const res = await this.$u.api.lCodedata(params)
				this.typegz = res.Data.Data.filter(item => item.ctype == gljbid);

			},
			confirmgz(e) {
				this.form.glzw = this.typegz[e[0]]
				console.log(this.typegz[e[0]])
			},
			async Store() {
				let $t = this
				let params = {
					ak: this.$store.state.token,
					cmd: 'lPeople_myupdate',
					para: {
						gljb: this.gljbid,
						glzw: this.form.glzw.id,
						qwhy: this.form.qwhy,
						zyyj: this.form.zyyj,
						"id": this.id
					}
				}
				const res = await this.$u.api.resumexgdata(params)
				if (res.ResponseID == 0) {
					this.$refs.uToast.show({
						title: res.Message,
						icon: false,
						duration: 800,
						callback() {
							uni.$emit('refreshData');
							uni.navigateBack({
								delta: 1
							})
						}
					})

				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.name-box {
		padding: 30rpx;
	}

	.navbar-right {
		margin-right: 30rpx;
		font-size: 30rpx;
	}
</style>
